package com.dana.friend.controller.question;

import com.core.domain.Result;
import com.core.domain.TableDataInfo;
import com.dana.friend.domain.question.Question;
import com.dana.friend.domain.question.dto.QuestionQueryDTO;
import com.dana.friend.domain.question.vo.QuestionDetailVO;
import com.dana.friend.domain.question.vo.QuestionVO;
import com.dana.friend.service.question.IQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/question")
public class QuestionController {
    @Autowired
    private IQuestionService questionService;
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
        return questionService.list(questionQueryDTO);
    }

    /**
     * 获取题目详情
     * @param questionId
     * @return
     */
    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId){
        return Result.ok(questionService.detail(questionId));
    }

    /**
     * 上一题
     * 将题目id缓存到redis中,根据题目id获取上下题
     * @param questionId
     * @return
     */
    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long questionId){
        return Result.ok(questionService.preQuestion(questionId));
    }
    /**
     * 下一题
     * 将题目id缓存到redis中,根据题目id获取上下题
     * @param questionId
     * @return
     */
    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long questionId){
        return Result.ok(questionService.nextQuestion(questionId));
    }
}
